#include "cCamera.h"
#include "cScene.h"
#define _USE_MATH_DEFINES
#include <math.h>


cCamera::cCamera(void)
{
}


cCamera::~cCamera(void)
{
}

void cCamera::Active(int idCam, float alpha, float beta, float x, float y, float z){
	float alpharad = alpha*M_PI/180;


	//vrp.x= obs.x - 1*sin(orientation*M_PI/180);
    //vrp.y= obs.y;
    //vrp.z= obs.z - 1*cos(orientation*M_PI/180);

	switch(idCam){
		case 0:	glTranslatef(0.0f,-2.0f,-40.0f);
				glRotatef(20,1.0f,0.0f,0.0f);
				break;

		case 1: 
			
			 GLfloat xaux;
			 xaux = x - 1*sin(alpharad);
			 GLfloat zaux;
			 zaux = z - 1*cos(alpharad);
			// gluLookAt(obs.x, obs.y, obs.z, vrp.x, vrp.y, vrp.z, 0, 1, 0);
			
			gluLookAt(x, 3.5, z, xaux, 3.5, zaux, 0, 1, 0);
				//glRotatef(-alpha,0.0f,1.0f,0.0f);
				//glRotatef(-beta,1.0f,0.0f,0.0f);
				
				//glTranslatef( -x  /*-(1.0f*sin(alpharad))*/, -3.5f, -z + 2/*-(1.0f*cos(alpharad))*/);
				
				//glTranslatef(-x , y+2.0f, -z+1.0f); //vista en primera persona
				break;

		case 2: gluLookAt(0, 20, 0, 0, 0, 0, 0, 0, 1); //vista en planta
				break;


	//	case 3: gluLookAt(8, 3.25, 0, 0, 0, 0, 0, 1, 0); //vista en perfil

		case 3: //gluLookAt(x-3.0f, 0, -z, 0, 0, 0, 0, 1, 0); //vista en perfil
				glRotatef(-90,0.0f,1.0f,0.0f); 
				glTranslatef(-x-5.0f, -2.5f,-z);
				break;

		case 4: gluLookAt(SCENE_WIDTH, SCENE_HEIGHT, SCENE_DEPTH, 0, 0, 0, 0, 1, 0); //cantonada
				break;

		case 5: gluLookAt(0, 0, 1, 0, 0, 0, 0, 1, 0); //des de l'interior
				break;

		case 6:	glRotatef(-alpha,0.0f,1.0f,0.0f); 
				//glRotatef(-beta,1.0f,0.0f,0.0f); 
				glTranslatef(-x-(2.0f*sin(alpharad)), -3.5f,-z-(2.0f*cos(alpharad))); //vista en tercera persona

				break;
	}
}
